package com.zhangfuyin.aop;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class LogAspect {

    @Pointcut("execution(* com.zhangfuyin..*(..))")
    public void pointCut(){

    }

    @Before("pointCut()")
    public void doBefore(){
        System.out.println("=================开始打印日志、doBefore()==============");
    }


    @AfterReturning(value = "pointCut()",returning = "result")
    public void doAfter(Object result){
        System.out.println("=================开始打印日志、doAfter()==============result = " + result);
    }


    @Around("pointCut()")
    public Object doAround(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("=================doAround() before==============");
        Object object = proceedingJoinPoint.proceed();
        String rtn = (String)object;

        rtn = rtn.toUpperCase();
        System.out.println("=================doAround() after==============");
        return rtn;
    }



}
